package com.msmall.community.roster.dao.hibernate;

import java.util.List;

import com.msmall.base.dao.hibernate.BaseDaoHibernate;
import com.msmall.community.roster.dao.RosterDao;
import com.msmall.community.roster.model.Roster;

public class RosterDaoHibernate extends BaseDaoHibernate<Roster,Long> implements RosterDao{
	
	public RosterDaoHibernate(){
		super(Roster.class);
	}
	/**
	 * 获得ownerid 对friendid的好友关系
	 */
	public Roster getRoster(Long ownerid, Long friendid) throws Exception{
		String queryString = "select r from Roster r, RosterGroup g where r.group.groupid=g.groupid and r.userid=? and g.userid=?";
		try{
			List list = getHibernateTemplate().find(queryString, new Object[]{friendid,ownerid});
			if(list != null && list.size() > 0){
				return (Roster) list.get(0);
			}
			return null;
		}catch(Exception e){
			throw e;
		}
	}
}
